Repository navigation
Conversation
…on an external drive Foundation read the whole file into memory (Ocarina: 4.8 GB dirty for the whole run)
betogzo
added a commit
to betogzo/nxnative
that referenced
this pull request
Nov 8, 2026
…dds#1817) and today's results: no flickering specks or pale patches, about 10 GB of memory, and the first-run freezes of mesh pipelines
seedds
added a commit
that referenced
this pull request
Nov 9, 2026
…o memory: it opened before the window in which a .mtl4a read asks for a mapping, so on an external drive Foundation read the whole file into memory (Ocarina of Time: footprint 19.0 → 12.2 GB, Malloc Large 5,032 → 135 MB, one 4.8 GB NSData). One window now covers every archive open in pso4_init, the bundled archive and the device's folder (PR #1817) Co-authored-by: Mariano Abad <1788933+fxd0h@users.noreply.github.com>
Owner
|
Landed in a1e155a with you as co-author, thanks for the diagnosis and the measurements. Two changes from the PR:
Tests: |
This was referenced Nov 9, 2026
Know-It-All-Brother
added a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
…o memory: it opened before the window in which a .mtl4a read asks for a mapping, so on an external drive Foundation read the whole file into memory (Ocarina of Time: footprint 19.0 → 12.2 GB, Malloc Large 5,032 → 135 MB, one 4.8 GB NSData). One window now covers every archive open in pso4_init, the bundled archive and the device's folder (PR seedds#1817) Co-authored-by: Mariano Abad <1788933+fxd0h@users.noreply.github.com>
nobz226
pushed a commit
to nobz226/nxnative
that referenced
this pull request
Nov 10, 2026
…o memory: it opened before the window in which a .mtl4a read asks for a mapping, so on an external drive Foundation read the whole file into memory (Ocarina of Time: footprint 19.0 → 12.2 GB, Malloc Large 5,032 → 135 MB, one 4.8 GB NSData). One window now covers every archive open in pso4_init, the bundled archive and the device's folder (PR seedds#1817) Co-authored-by: Mariano Abad <1788933+fxd0h@users.noreply.github.com> (cherry picked from commit a1e155a)
Fasen24-AI
added a commit
to Fasen24-AI/swordboiMacNative
that referenced
this pull request
Nov 10, 2026
…r words), seedds#1817 (bundled archive mapped), DM_NVN_COND_CONSERVATIVE (samples-passed conditions keep drawing: an A/B for frame-time flicker) Upstream pull requests applied in this commit (their authors' work, brought onto this tree with a three-way merge; the description is in each PR): - seedds#1813 by uncraftablexd (closed): A 64- or 128-bit raw global load that misses every pool reads 0 in all its words again, as the word loads it replaced did: the vector helper returned 0 for word 0 but never wrote gmem_vec, so words 1..3 read the previous load's words or undefined data; a vector load's follower scan takes only its own LDG's words (chain 6ed0e0a1fc9f) - seedds#1817 by fxd0h (closed): The pipeline archive bundled with the app is mapped too, not read into memory
seedds
added a commit
that referenced
this pull request
Nov 14, 2026
…cold bundled archive opens 3-6x faster (PR #2657) Metal's open (MTL4ArchiveImpl::loadFromURL) hashes every Metal library in the file on the calling thread: the whole __AIR_DATA segment and __TEXT,__metallib section of each GPU image (2.9 GB of Ocarina of Time's 4.4 GB applegpu_g16s file). With the archive mapped (the mapped reader of PR #1817, kept), a file that is not in memory is read one page fault at a time, about 230 MB/s: the gray screen before the pipeline progress screen on an M4 Max. arch_open now asks for those ranges first, from the load commands arch_file_ok already walks: 8 MB pieces on every core, each mapped on its own, given MADV_WILLNEED and unmapped, so the kernel reads them into the file cache Metal's mapping shares. It is used for the bundled archive, the bundle's prewarm files and the device's folder, all inside the mapped reader's window. The PR read each piece into an 8 MB heap buffer: as fast, but malloc kept the freed buffers (+99 MB of footprint after the open on a 12-core M6) and a warm open copied every byte again. One mapping of the whole file is ruled out because Metal maps it too (two of a 4.4 GB file do not fit an iPhone's address space); F_RDADVISE was erratic (0.34-12.9 s cold). Measured, each cold run on a fresh APFS clone on an external drive: - M4 Max, the PR's version: Ocarina of Time's bundled archive in the game 10.57 / 8.07 s -> 1.63 / 1.53 s - M6, this version, the host's open path inside the mapped reader's window: Divinity: Original Sin 2's bundled archive (373 MB) 0.99-1.58 s -> 0.34 s cold, warm 92-97 -> 99-103 ms; 16 of Ocarina of Time's device files in parallel (1.8 GB) 0.93-1.26 -> 0.64-0.77 s cold, warm 81-82 -> 91-98 ms; footprint after the open the same - M6, Fast Fusion booted with hosts built from main and from this change (2 runs a side): the bundled archive (74 MB) 1062 / 856 -> 176 / 145 ms, its prewarm file, device folder and the three together 0.99-1.31 -> 0.38-0.47 s; both at 60 fps past frame 2,400, peak memory 2,423 vs 2,416-2,418 MB, the same one red line on both Checked: t_pso_bundle (83), t_pso_archive (14), t_pso_prewarm (64), test_docs. Not run: regress.py check (one game booted instead: the change alters how pages reach memory, not what Metal opens), clang-tidy (not installed here), iOS. Co-authored-by: NicoPV94 <17337435+NicoPV94@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
arch_open_beginmakes a.mtl4aread ask for a mapping, since Foundation reads a file on an external drive into memory instead (A pipeline archive on an external drive is read into memory).pso_bundle_openran before that window opened, so the app's ownResources/pso/<gpu>.mtl4awas still read whole when the app sits on an external drive. It now opens inside the window. One line, plus a paragraph in that reference entry.Checked
Tests:
t_pso_bundle(69),t_pso_archive(135),test_docs.py; host builds for 0400486024DEC000.Ocarina of Time (0400486024DEC000, v131072), app on an external SSD over USB, same save and scene:
NSData)M5 Max, macOS 27.2.
No
regress.pyrun: the change only moves when an existing hook is installed, and it reaches only a Mac app with a bundled archive on an external drive. iOS isn't touched (its files are on the internal disk).